import { createApp } from 'vue'
import Options from './Options.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { createPinia } from 'pinia'

// 抑制 ResizeObserver 警告
const resizeObserverErr = ResizeObserverLoopErr => ResizeObserverLoopErr.replace('ResizeObserver loop completed with undelivered notifications.', '');
window.addEventListener('error', e => {
  if (e.message === 'ResizeObserver loop completed with undelivered notifications.') {
    e.stopImmediatePropagation();
  }
});

const app = createApp(Options)
app.use(ElementPlus)
app.use(createPinia())

// 注册所有 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 全局注册 ElMessage 和 ElMessageBox
app.config.globalProperties.$message = ElMessage
app.config.globalProperties.$confirm = ElMessageBox

app.mount('#app')